import requests
import execjs


headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
}

url = "https://music.163.com/weapi/song/enhance/player/url/v1"
params = {
    "csrf_token": "45165d1641bd55361205374cbfab53d7"
}
with open(r'E:\Python\vscode\Crawlers\js逆向\08网易云音乐_歌曲\data_a.js','r',encoding='utf-8') as f:
    js = execjs.compile(f.read())

i5n = {
    "ids": "[36199531]",
    "level": "exhigh",
    "encodeType": "aac",
    "csrf_token": "45165d1641bd55361205374cbfab53d7"
};


data = js.call('get_key',i5n)
response = requests.post(url, headers=headers, params=params, data=data)
json_data = response.json()
print(json_data.get('data')[0]['url'])
music_data = requests.get(json_data.get('data')[0]['url'], headers=headers)